<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>管理后台</title>
    <link rel="shortcut icon" href="/favicon.ico">
    <link href="/public/admin/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="/public/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="/public/admin/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="/public/admin/css/animate.css" rel="stylesheet">
    <link href="/public/admin/css/style.css?v=4.0.0" rel="stylesheet">
    <link href="/public/admin/js/plugins/layer/skin/layer.css" rel="stylesheet">
    <base target="_blank">
    <!-- 全局js -->
    <script src="/public/admin/js/jquery.min.js?v=2.1.4"></script>
    <script src="/public/admin/js/bootstrap.min.js?v=3.3.5"></script>
    <script src="/public/admin/js/plugins/layer/layer.min.js"></script>
    <!-- 自定义js -->
    <script src="/public/admin/js/content.js?v=1.0.0"></script>
    <script src="/public/admin/js/contabs.js"></script>
    <script src="/public/admin/js/common.js"></script>
    <script src="/public/admin/js/article.js"></script>

    <!-- Bootstrap table -->
    <script src="/public/admin/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
    <script src="/public/admin/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
    <script src="/public/admin/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-xs-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>信息列表</h5>
                </div>
                <div class="ibox-content">
                    <div class="box-header">
                        <div class="panel-body">
                            <form action="" id="search-form2" class="form-inline" method="get" action="{:url('user/index')}" target="_self">
                                <label class="control-label" for="input-patient_name">病人姓名</label>
                                <div class="input-group" style="width:100px;">
                                    <input type="text" name="patient_name" value="{$inputData['patient_name']}" placeholder="姓名" id="input-patient_name" class="form-control">
                                </div>
                                <label class="control-label" for="input-patient">记账号</label>
                                <div class="input-group" style="width:100px;">
                                    <input type="text" name="patient_id" value="{$inputData['patient_id']}" placeholder="记账号" id="input-patient_id" class="form-control">
                                </div>
                                <label class="control-label" for="input-department_code">科室代码</label>
                                <div class="input-group" style="width:100px;">
                                    <input type="text" name="department_code" value="{$inputData['department_code']}" placeholder="科室代码" id="input-department_code" class="form-control">
                                </div>
                                <label class="control-label" for="input-rfid">RFID号码</label>
                                <div class="input-group">
                                    <input type="text" name="rfid" value="{$inputData['rfid']}" placeholder="RFID号码" id="input-rfid" class="form-control">
                                </div>
                                <button type="submit" id="button-filter search-order" class="btn btn-primary" id="fileForm"><i class="fa fa-search"></i> 筛选</button>
                                
                                <label class="control-label" for="input-out_sign" style="margin-left:50px;">临时外出/返回：</label>
                                <div class="input-group" style="width:180px;">
                                    <input type="text" name="out_sign" value="{$inputData['out_sign']}" placeholder="腕带标签滴卡处" id="input-out_sign" class="form-control" onkeydown="return disableTextSubmit(event)">
                                </div>
                            </form>
                            <script>
                                function disableTextSubmit(e) {
                                    if (e.keyCode == 13) {
                                        var code = $("#input-out_sign").val();
                                        var param = {rfid : code};
                                        $.post("{:url('Outsign/out_sign')}", param, function(data) {
                                            layer.msg(data.msg,function(){
                                                window.location.href = location.href;
                                            });
                                            gofocus();
                                        },"JSON");
                                        return false;
                                    }
                                }
                                gofocus();
                                function gofocus(){
                                    $("#input-out_sign").val("");
                                    $("#input-out_sign").focus();
                                }

                                var requestcode=1;
                                function importExcel(){
                                    if( requestcode != 1 ){
                                        layer.msg('提交请求中，请稍候');
                                        return false;
                                    }
                                    var formData = new FormData($('#search-form2')[0]);
                                        formData.append('file',$('#excelfile')[0].files[0]);
                                    $.ajax({
                                        type:'post',
                                        url:"{:url('user/importExcel')}",
                                        cache: false,
                                        processData: false,
                                        contentType: false,
                                        async: false,
                                        data:formData,
                                        dataType:'json',
                                        success:function(res){
                                            if(res.status==1){
                                                layer.msg(res.msg,{time:1000},function(){
                                                    window.location = window.location;
                                                });
                                            }else{
                                                layer.msg(res.msg);
                                            }
                                            setTimeout(function(){
                                                requestcode = 1;
                                            },500);
                                        }

                                    });
                                    requestcode = 0;
                                    return false;
                                }
                            </script>
                        </div>
                        <div id="ajax_return">

                            <form method="post" enctype="multipart/form-data" target="_self" id="form-order">
                                <div class="table-responsive">
                                    <table class="table table-bordered table-hover">
                                        <thead>
                                        <tr>
                                            <th style="width: 1px;display:none"><input type="checkbox" onclick="$('input[name*=\'selected\']').prop('checked', this.checked);"></th>
                                            <th>ID</th>
                                            <th>记账号</th>
                                            <th>病人姓名</th>
                                            <th>性别</th>
                                            <th>年龄</th>
                                            <th>科室名称</th>
                                            <th>科室代码</th>
                                            <th>RFID</th>
                                            <th>外出时间</th>
                                            <th>回来时间</th>
                                            <th>操作</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        {volist name="list" id="v"}
                                            <tr>
                                                <td style="display:none">
                                                    <input type="checkbox" name="selected[]" value="{$v.id}">
                                                </td>
                                                <td>{$v.id}</td>
                                                <td>{$v.patient_id}</td>
                                                <td>{$v.patient_name}</td>
                                                <td>{eq name="v.gender" value="1"}男{else/}女{/eq}</td>
                                                <td>{$v.age}</td>
                                                <td>{$v.department}</td>
                                                <td>{$v.department_code}</td>
                                                <td>{$v.rfid}</td>
                                                <td>{$v.starttime|date="Y-m-d H:i:s"}</td>
                                                <td>{empty name="v['endtime']"}-{else/}{$v.endtime|date="Y-m-d H:i:s"}{/empty}</td>
                                                <td>
                                                    <a href="javascript:void(0);" onclick="del('{$v.id}',this)" id="button-delete6" data-toggle="tooltip" title="删除" class="btn btn-danger" data-original-title="删除" target="_self"><i class="fa fa-trash-o"></i></a>
                                                </td>
                                            </tr>
                                        {/volist}
                                        </tbody>
                                    </table>
                                </div>
                            </form>
                            <div class="row">
                                <div class="col-sm-6 text-left" style="display:none"><a href="javascript:void(0);" onclick="delselect()" id="button-delete6" data-toggle="tooltip" title="删除" class="btn btn-danger" data-original-title="删除">删除选中</a></div>
                                <div class="col-sm-6 text-right">{$page|raw}</div>
                            </div>
                        <script>
                            // 点击分页触发的事件
                            // $(".pagination a").click(function(){
                            //     url = $(this).attr('href');
                            //     ajax_get_url('search-form2',url);
                            //     return false;
                            // });
                            // 删除选中
                            function delselect(){
                                parent.layer.confirm('确定要删除选中吗？', function(){
                                    $.ajax({
                                        url:"/index.php/Admin/patient/delselect",
                                        data : $('#form-order').serialize(),
                                        success: function(v){
                                            var v =  eval('('+v+')');
                                            parent.layer.msg(v.msg, {icon: v.icon,time: 1000});
                                            if(v.hasOwnProperty('status') && (v.status == 1))
                                                ajax_get_table('search-form2',cur_page);
                                        }
                                    });
                                });
                            }
                            //
                        </script>

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

</div>
<input id="handle_status" value="" hidden="hidden">


<div class="modal fade" id="bjy-add" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">选择外出原因</h4>
            </div>
            <div class="modal-body">
                <form id="bjy-form" class="form-horizontal" action="{:url('Admin/Outrecord/form')}" method="post" target="_self">
                    <div class="form-group">
                        <input type="hidden" name="patient_id">
                        <label class="col-sm-2 control-label">原因：</label>
                        <div class="col-sm-8">
                            <select class="form-control" name="equipgroup_id">
                            {foreach name="equipgroup_list" item="v"}
                                <option value="{$v.id}">{$v.group_name}</option>
                            {/foreach}
                            </select>
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>
                    <div class="form-group">
                        <div class="col-sm-3 col-sm-offset-3">
                            <button class="btn btn-primary" type="submit">提交</button>
                        </div>
                    </div> 
                </form>
            </div>
        </div>
    </div>
</div>


<script>
// 添加菜单
    function add(obj){
        var dataId  = $(obj).attr('dataId');
        $("input[name='patient_id']").val(dataId);
        $('#bjy-add').modal('show');
    }
    // $(document).ready(function(){
    //     ajax_get_table('search-form2',1);
    // });

    function openLayer(url,name){
        parent.layer.open({
            type: 2,
            title: name,
            shade: 0.5,
            shadeClose : false,
            maxmin: true, //开启最大化最小化按钮
            area: ['70%', '80%'],
            content: url,
            end : function(){
                var handle_status = $("#handle_status").val();
                if(handle_status == '1'){
                    window.location.href = location.href;
                }
            }
        });
    }

    // 删除操作
    function del(id,obj) {
        top.layer.confirm('确定删除该记录？',{
            icon : 3,
            btn:['确定','取消'],
        } , function(){
            $.ajax({
                url :'/index.php/Admin/Outrecord/mainDel',
                type : "post",
                data : {id:id},
                dataType : "json",
                success:function(data){
                    if (data.status == 0) {
                        top.layer.msg(data.message);
                    } else {
                        top.layer.msg(data.message);
                        $(obj).parent().parent().remove();
                        var total = $("#total").html()-1;
                        $("#total").html(total);
                    }
                }
            });
        } , function(){
            layer.close(); //再执行关闭
        })
    }


    // 点击排序
    function sort(field){
        $("input[name='order_by']").val(field);
        var v = $("input[name='sort']").val() == 'desc' ? 'asc' : 'desc';
        $("input[name='sort']").val(v);
        ajax_get_table('search-form2',cur_page);
    }

    // setTimeout(function(){
    //     window.location.href = location.href;
    // },15000);

    
</script>
</body>
</html>